package com.lancoo.znbkxx.teacher.ui.activity

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.base.BaseVMActivity
import com.lancoo.znbkxx.teacher.base.BaseViewModel
import com.lancoo.znbkxx.teacher.databinding.ActivityOneononeBinding
import com.lancoo.znbkxx.teacher.ui.fragment.*
import kotlinx.android.synthetic.main.activity_oneonone.*

/**
 * @author : wealive
 * @date   : 2020/9/29 11:33
 * @desc   :
 */
class OneonOneActivity : BaseVMActivity<BaseViewModel, ActivityOneononeBinding>() {
    override fun providerVMClass(): Class<BaseViewModel>? {
        return BaseViewModel::class.java
    }

    override fun setLayoutID(): Int {
        return R.layout.activity_oneonone
    }

    override fun initView() {
        vp.isUserInputEnabled = false
        vp.offscreenPageLimit = 4
        vp.adapter = object : FragmentStateAdapter(supportFragmentManager, lifecycle) {
            override fun getItemCount(): Int {
                return 5
            }

            override fun createFragment(position: Int): Fragment {
                return when (position) {
                    0 -> OnlineTutorFragment()
                    1 -> SkillCommentFragment()
                    2 -> WrongCommentFragment()
                    3 -> DignosisOneOnOneFragment()
                    else -> PersonalCenterFragment()
                }
            }
        }
        binding.bottomNav.itemIconTintList = null
        binding.bottomNav.setOnNavigationItemSelectedListener(
                BottomNavigationView.OnNavigationItemSelectedListener {
                    when (it.itemId) {
                        R.id.navigation_tutor -> {
                            binding.vp.setCurrentItem(0, false)
                            return@OnNavigationItemSelectedListener true
                        }
                        R.id.navigation_skill -> {
                            binding.vp.setCurrentItem(1, false)
                            return@OnNavigationItemSelectedListener true
                        }
                        R.id.navigation_problemcounseling -> {
                            binding.vp.setCurrentItem(2, false)
                            return@OnNavigationItemSelectedListener true
                        }
                        R.id.navigation_analysis -> {
                            binding.vp.setCurrentItem(3, false)
                            return@OnNavigationItemSelectedListener true
                        }
                        R.id.navigation_personalcenter -> {
                            binding.vp.setCurrentItem(4, false)
                            return@OnNavigationItemSelectedListener true
                        }
                    }
                    false
                })
    }
}